#!/bin/bash
myid=$1
tar zxvf zookeeper-3.4.14.tar.gz -C /usr/local/
ln -s /usr/local/zookeeper-3.4.14/ /usr/local/zookeeper
mkdir /usr/local/zookeeper/data/ -p
echo myid > /usr/local/zookeeper/data/myid
mv /usr/local/zookeeper/conf/zoo_sample.cfg /usr/local/zookeeper/conf/zoo.cfg 
sed -i 's#dataDir=.*#dataDir=/usr/local/zookeeper/data#g' /usr/local/zookeeper/conf/zoo.cfg

{
cat <<'zoo'
server.1=192.168.9.41:2888:3888
server.2=192.168.9.42:2888:3888
server.3=192.168.9.43:2888:3888
zoo
} >> /usr/local/zookeeper/conf/zoo.cfg

